﻿<!DOCTYPE html>
<html>
<head>
    <title>CGI</title>
</head>
<body>
    <h1>Our Page</h1>
    <script>
        //01
        //blank object project with property with name/value pair. added by dot dot notation
        //name = name and value = Project Cigna, also can hold functions
       
        var project = new Object();
        project.name = 'Project Cigna';
        project.securityLevel = 15;
        project.updateDueDate = function () {
            return true;
        };
        console.log(project.name);
        console.log(project.updateDueDate());
        console.log(project.securityLevel);
        console.log(project['securityLevel']);

        //real code (hard code elimination) dynamic access to property
        var field = 'securityLevel';
        console.log(project[field]);
        

        //02
        //using JSON to create an object
        //no field in braces create an empty object
        /*
        var project = {};
        project.name = 'Project Cigna';
        console.log(project.name);
        */

        //03
        //all encapsulate with more sense to use JSON, easier to read
        /*
        var project = {
            name: 'Project Cigna',
            securityLevel: 15,
            updateDueDate: function () { return true; }
        };
        console.log(project.name);

        var project = {
            name: 'ProjectPhoenix',
            securityLevel: 15,
            updateDueDate: function () {
                return true;
            },
            team: ['ISGMQ', 'CDS', 'CBH']
        };
        console.log(project.team[2]);
        */

        //04
        //array having 2 objects taskName: 'first' & taskName: 'second'
        /*
        var project = {
            tasks: [
                {
                    taskName: 'first'
                },
                {
                    taskName: 'second'
                }
            ]
        };
        console.log(project.tasks[1].taskName);
        */
    </script>
</body>
</html>